package com.rabincorp.tactile.action;

import com.rabincorp.tactile.common.TactileCommon;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;

import com.rabincorp.tactile.entity.YouTubeVideoItem;
import com.rabincorp.tactile.util.CacheService;

public class HomeAction extends BaseAction {

    private static final Logger LOGGER = Logger.getLogger(HomeAction.class.getName());

    @Override
    @SuppressWarnings("unchecked")
    protected String execute(ActionForm form, HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        List<YouTubeVideoItem> cacheContent = (List<YouTubeVideoItem>) CacheService.getDefault().getCachedObject(TactileCommon.CACHE_SERVICE_NAME, TactileCommon.CACHE_YOUTUBE_ID);
        if (cacheContent != null) {
            request.setAttribute("videoList", cacheContent);
        }

        return FORWARD_SUCCESS;
    }
}
